home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Source Code
/
Libraries
/
Graphic Elements 3
/
GEDemo
/
Sign.c
< prev
next >
Wrap
Text File
|
1994-09-24
|
2KB
|
85 lines
/*
Sign.c
User-entered text for Graphic Elements demo
Copyright 1993 by Al Evans. All rights reserved.
11/11/93
*/
#include "Sign.h"
Str255 signText = "\pMessage Here!";
typedef struct {
Boolean signOn;
RGBColor color[2];
} BlinkRec, *BlinkRecPtr;
//BlinkRec signBlink;
pascal void DisposeSign(GEWorldPtr world, GrafElPtr element)
{
if (element->changeData)
DisposPtr(element->changeData);
}
Boolean LoadSignScene(GEWorldPtr world)
{
GrafElPtr thisElement;
short fontNum;
BlinkRecPtr signBlink;
GetFNum("\pChicago", &fontNum);
signBlink = (BlinkRecPtr) NewPtr(sizeof(BlinkRec));
signBlink->signOn = false;
signBlink->color[0].red = 194 << 8;
signBlink->color[0].green = 194 << 8;
signBlink->color[0].blue = 0;
signBlink->color[1].red = 240 << 8;
signBlink->color[1].green = 240 << 8;
signBlink->color[1].blue = 46 << 8;
//Create sign
thisElement = NewTextGraphic(world, signID, signPlane, signLeft, signTop, srcOr,
fontNum, bold, 18, signBlink->color[signBlink->signOn], signText);
if (!thisElement) return false;
//Initialize blinking action
SetAutoChange(world, signID, DoSign, (Ptr) signBlink, 750);
//Be sure to Dispose blink record
SetCleanupProc(world, signID, DisposeSign);
return true;
}
pascal void DoSign(GEWorldPtr world, GrafElPtr sign)
{
#pragma unused (world)
BlinkRecPtr blink;
blink = (BlinkRecPtr) sign->changeData;
blink->signOn = !blink->signOn;
((TextGraphicPtr) sign)->tgColor = blink->color[blink->signOn];
ChangedRect(world, &sign->animationRect);
}
pascal void GetSignText(StringPtr oldText)
{
BlockMove((Ptr) signText, (Ptr) oldText, (long) *signText + 1);
}
//Change sign text
pascal void SetSignText(GEWorldPtr world, StringPtr newText)
{
BlockMove((Ptr) newText, (Ptr) signText, (long) *newText + 1);
SetTextGraphicText(world, signID, signText);
}